package com.crealth.memcached;

import com.crealth.db.CompanyDb;
import com.crealth.model.CompanyModel;

public class CompanyCached {
	private static final String companyKey = "company_id_";
	
	public static CompanyModel selectCompanyByID(int companyID) {
		String key = companyKey + companyID;
		Object obj = MemcachedMgr.cachedClient.get(key);
		CompanyModel company = null;
		if (obj != null) {
			company = (CompanyModel)obj;
		}
		else {
			company = CompanyDb.selectCompanyByID(companyID);
			if (company != null) {
				MemcachedMgr.cachedClient.set(key, company);
			}
		}
		
		return company;
	}
	
}
